#include<iostream>
#include <cstdio>
using namespace std;
int zr[3];
int count=0;
int isLeap(int year){
    if((year%400) == 0 || ((year%4)==0 && (year%100)!=0 )){
        return 1;
    }
    else{
        return 0;
    }
}
void check(int year,int month,int day){
	int days[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	if(year>=60){
		year+=1900;
	}
	else{
		year+=2000;
	}
	if(month>12){
		return;
	}
	if(isLeap(year)){
		days[1]=29;
	}
	if(day>days[month-1]){
		return;
	}
	zr[count]=(year*10000)+(month*100)+day;
	count++;
}
int main(){
	int x,y,z,year,month,day;
	scanf("%d/%d/%d",&x,&y,&z);
    if(x==y && y==z){
        check(x,y,z);
    }
	else if(y==x){
		check(x,y,z);
		check(z,x,y);
	}
    else if(x==z){
		check(z,x,y);
		check(z,y,x);
    }
	else{
		check(x,y,z);
		check(z,x,y);
		check(z,y,x);
	}
	if(count==0){
		cout<<"None";
	}
	else if(count==1){
		day=(zr[0]%100);
		zr[0]/=100;
		month=(zr[0]%100);
		zr[0]/=100;
		year=zr[0];
		printf("%d-%02d-%02d",year,month,day);
	}
	else{
		for(int i=0;i<count-1;i++){
			for(int j=0;j<count-1-j;j++){
				if(zr[j]>zr[j+1]){
					int c=zr[j];
					zr[j]=zr[j+1];
					zr[j+1]=c;
				}
			}
		}
		for(int i=0;i<count-1;i++){
			day=(zr[i]%100);
			zr[i]/=100;
			month=(zr[i]%100);
			zr[i]/=100;
			year=zr[i];
			printf("%d-%02d-%02d\n",year,month,day);
		}
		day=(zr[count-1]%100);
		zr[count-1]/=100;
		month=(zr[count-1]%100);
		zr[count-1]/=100;
		year=zr[count-1];
		printf("%d-%02d-%02d",year,month,day);
	}
}
